using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PlayStory
{

    public class Game1 : Microsoft.Xna.Framework.Game
    {
        private GraphicsDeviceManager graphics;
        private SpriteBatch spriteBatch;
        private Gameplay gameplay;
        private Menu menu;
        private String currentScreen;
        public SpriteFont font;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            graphics.PreferredBackBufferWidth = 1920;
            graphics.PreferredBackBufferHeight = 1080;
            graphics.IsFullScreen = false;
        }

        protected override void Initialize()
        {
            menu = new Menu(this);
            currentScreen = "startScreen";
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("fonts/font1");
            menu.LoadContent();
        }

        protected override void Update(GameTime gameTime)
        {
            switch (currentScreen)
            {
                case "startScreen":
                    menu.Update(gameTime);
                    break;                
                case "gamePlay":
                    gameplay.Update(gameTime);
                    break;
                //case "gameOver":
                //    gameOverScreen.Update();
                //    break;

            }

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.AliceBlue);
            switch (currentScreen)
            {
                case "startScreen":
                    menu.Draw(gameTime);
                    break;
                case "gamePlay":
                    gameplay.Draw(gameTime);
                    break;
                //case "gameOver":
                //    gameOverScreen.Draw(gameTime);
                //    break;
            }
            base.Draw(gameTime);
        }

        public void startGame(Texture2D[] image, IDictionary<int, menuAction> zuordnung)
        {
            //graphics.ToggleFullScreen();
            gameplay = new Gameplay(this);
            gameplay.LoadContent(image, zuordnung);
            currentScreen = "gamePlay";
        }
    }
}
